﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace LitTools
{
    [CreateAssetMenu(menuName = "LitAssets/LitAudio/AudioClipCatalog")]
    public class AudioClipCatalog : ScriptableObject
    {
        public string Id;
        [SerializeField] private List<AudioClipInfo> audioClipList;
        /// <summary>
        /// 通过id获取声音片段信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AudioClipInfo GetAudioClipInfoById(string id)
        {
            if (audioClipList == null
                || audioClipList.Count == 0)
            {
                Debug.LogError($"[LitAudio] 名字为{name}的声音目录为空");
                return null;
            }
            for (int i = 0; i < audioClipList.Count; i++)
            {
                if (audioClipList[i].id == id)
                    return audioClipList[i];
            }
            Debug.LogError($"[LitAudio] 名字为:{name}的声音目录中找不到id为{id}的声音信息");
            return null;
        }

    }
}